package com.example.fluentmybatis.controller;

import cn.hutool.core.bean.BeanUtil;
import com.example.fluentmybatis.entity.CodeGeneratorEntry;
import com.example.fluentmybatis.service.ICodeGeneratorService;
import com.example.fluentmybatis.vo.CodeGeneratorVO;
import com.example.fluentmybatis.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : Mr Li
 * @description : 后台管理系统-代码生成处理层
 * @since : 2021/8/4 10:44 上午
 */
@RestController
@RequestMapping("backStageServer-codeGeneratorController")
public class CodeGeneratorController {

    @Autowired
    private ICodeGeneratorService codeGeneratorService;

    /**
     * 生成代码
     *
     * @param codeGeneratorVO 所需实体参数VO
     * @return 生成结果
     */
    @PostMapping("/generatorCode")
    public R<Boolean> generatorCode(@RequestBody CodeGeneratorVO codeGeneratorVO){
        var codeGeneratorEntry = new CodeGeneratorEntry();
        BeanUtil.copyProperties(codeGeneratorVO,codeGeneratorEntry);
        codeGeneratorService.codeGenerator(codeGeneratorEntry);
        return R.ok(Boolean.TRUE);
    }


}
